import {track, trigger} from './effect.js'
import {isObject} from "./utils.js";
import {handlers} from "./handlers.js";


const targetMap = new WeakMap();

export function reactive(target) {
  if (!isObject(target)) {
    // 如果不是对象，直接返回
    return target;
  }
  if (targetMap.has(target)) {
    // 如果已经代理过了，直接返回
    return targetMap.get(target);
  }
  const proxy = new Proxy(target, handlers);
  targetMap.set(target, proxy);
  return proxy;
}
